Skip to content

chore: backfill email-domain member organization dates (CM-1107)#4061

Merged
skwowet merged 1 commit intoimprove/CM-1105from
script/CM-1107
Apr 28, 2026
Merged

chore: backfill email-domain member organization dates (CM-1107)#4061
skwowet merged 1 commit intoimprove/CM-1105from
script/CM-1107

Conversation

@skwowet
Copy link
Copy Markdown
Collaborator

@skwowet skwowet commented Apr 28, 2026

Summary

Adds a one-off backfill script for existing email-domain member organization rows with missing dates.

The script:

  • Finds active email-domain member organizations where dateStart and dateEnd are null.
  • Uses verified email identities and activityRelations.memberId/platform/username to find activity-date evidence.
  • Reuses the stint inference logic to apply date ranges.
  • Queues changed members in Redis for affiliation recalculation.

Note

Medium Risk
Adds a one-off script that writes to memberOrganizations and queues affiliation recalculation, plus changes the Redis set key used for that recalc queue; mistakes could cause incorrect date ranges or missed/duplicated recalcs.

Overview
Adds a one-off backfill script to populate missing dateStart/dateEnd for existing email-domain memberOrganizations by deriving activity-based dates and applying the existing stint-inference logic, then enqueuing affected members for affiliation recalculation.

Extends the data-access layer with queries to (1) page through members with undated email-domain org rows and (2) fetch per-member activity dates via verified email identities + activityRelations. Also standardizes the Redis queue key for affiliation recalculation to recalculate-member-affiliations and wires the new script into backend/package.json.

Reviewed by Cursor Bugbot for commit 53b83d3. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 08:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a one-off operational backfill to infer and populate missing dateStart/dateEnd for existing email-domain member-organization rows, using verified email identities + activity relations as evidence and reusing existing stint inference logic.

Changes:

  • Extend data-access-layer with queries to (a) page through members with undated email-domain org rows and (b) fetch per-org activity-date evidence derived from verified email identities.
  • Add a backend CLI script to run the backfill, apply inferred inserts/updates in transactions, and enqueue affected members for affiliation recalculation via Redis.
  • Update the script-executor worker’s Redis set key used for member affiliation recalculation.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/libs/data-access-layer/src/members/types.ts Adds a typed shape for activity-date evidence used by the new DAL query.
services/libs/data-access-layer/src/members/organizations.ts Introduces DAL fetchers for undated email-domain members and their activity-date evidence.
services/apps/script_executor_worker/src/activities/block-project-organization-affiliations.ts Switches the Redis set key used to queue/drain members for affiliation recalculation.
backend/src/bin/scripts/backfill-email-domain-member-organization-dates.ts New one-off backfill script to infer/apply date ranges and enqueue members for recalculation.
backend/package.json Adds an npm script entry to run the new backfill script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@skwowet skwowet marked this pull request as ready for review April 28, 2026 12:53
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 53b83d3. Configure here.

@skwowet skwowet merged commit ade866b into improve/CM-1105 Apr 28, 2026
16 checks passed
@skwowet skwowet deleted the script/CM-1107 branch April 28, 2026 13:01
@skwowet skwowet restored the script/CM-1107 branch April 28, 2026 13:01
skwowet added a commit that referenced this pull request Apr 28, 2026
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants